package com.wolfking.jeesite.freemarker.method;

import com.google.common.collect.Lists;
import com.wolfking.jeesite.freemarker.FreemarkerMethod;
import com.wolfking.jeesite.service.DictService;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * freemarker的权限的标签
 * <p>
 *
 * @author wolfking@赵伟伟
 * @mail zww199009@163.com
 * @创作日期 2017年4月28日下午3:50:30
 * @版权 归wolfking所有
 */
@Slf4j
@FreemarkerMethod("getDict")
public class GetDictMethod implements TemplateMethodModelEx {

    @Autowired
    private DictService dictService;

    @Override
    public Object exec(List list) throws TemplateModelException {
        if (list.size() == 1) {
            String type = list.get(0).toString();
            return dictService.getByType(type);
        }
        return Lists.newArrayList();
    }
}
